package com.burgeon.backend.SHOPBACKEND.controller;

import com.burgeon.backend.SHOPBACKEND.entity.BargainVO;
import com.burgeon.backend.SHOPBACKEND.entity.Goods;
import com.burgeon.backend.SHOPBACKEND.service.BackendBargainService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("shopbackent/bargain")
@RestController
@CrossOrigin
public class BackendBargainController extends BaseController {

    @Autowired
    private BackendBargainService backendBargainService;

    @RequestMapping("item")
    public ResponseResult<Goods> getItemData(String gid) {
        Goods data = backendBargainService.getGoodsById(gid);
        return new ResponseResult<Goods>(SUCCESS,data);
    }

    @RequestMapping("list")
    public ResponseResult<List<BargainVO>> getList(String account) {
        List<BargainVO> data = backendBargainService.getListData(account);
        return new ResponseResult<List<BargainVO>>(SUCCESS,data);
    }

    @RequestMapping("del")
    public ResponseResult<Void> delData(String id) {
        backendBargainService.delData(id);
        return new ResponseResult<>(SUCCESS);
    }

    @RequestMapping("upState")
    public ResponseResult<Void> upState(String id,String state) {
        backendBargainService.upState(id,state);
        return new ResponseResult<>(SUCCESS);
    }

    @RequestMapping("createData")
    public ResponseResult<Void> createData(BargainVO bargainVO) {
        backendBargainService.createBargain(bargainVO);
        return new ResponseResult<>(SUCCESS);
    }


}
